Skip to content

feat(kernels): add cancel session command - #1173

Closed
ternaus wants to merge 1 commit into
Kaggle:mainfrom
ternaus:codex/kernels-cancel-session
Closed

feat(kernels): add cancel session command#1173
ternaus wants to merge 1 commit into
Kaggle:mainfrom
ternaus:codex/kernels-cancel-session

Conversation

@ternaus

@ternaus ternaus commented Aug 10, 2026

Copy link
Copy Markdown

Summary

  • add kaggle kernels cancel <SESSION_ID>
  • call the existing ApiCancelKernelSessionRequest endpoint and surface API rejections
  • document that <SESSION_ID> is the numeric version printed by kaggle kernels push

The CLI exposed status and logs for a run but no way to stop a queued or running session without using the web UI or private SDK code.

Closes #1172.

Validation

  • PYTHONPATH=src python -m pytest tests/unit -q (1,257 passed)
  • hatch run lint:typing
  • black --check on the changed Python files

Expose the existing kernel-session cancellation API through the CLI, with validation, tests, and command documentation.
@sridipbasu

Copy link
Copy Markdown
Contributor

Hey @ternaus,

I am an external reviewer

I went through the kernels cancel changes and tested the command. The API side looks fine, but I noticed an issue with the way the SESSION_ID is documented.

The docs say that the session ID is the versionNumber printed after kaggle kernels push. But from what I could trace, versionNumber and kernelSessionId are actually different things.

For example, if kernels push prints:

Kernel version 3 successfully pushed

the docs would lead a user to try:

kaggle kernels cancel 3

But the cancel API is expecting the kernelSessionId, not the kernel version number.

So I think the current documentation could cause users to pass the wrong ID and the command won't cancel the session they intended to.

Could you please update the documentation/help text to clarify that this command needs the actual kernelSessionId and explain where the user can get it?

Thanks!

@ternaus
ternaus marked this pull request as ready for review August 10, 2026 18:13
@ternaus

ternaus commented Aug 10, 2026

Copy link
Copy Markdown
Author

Thanks for the careful review. I rechecked this against the public session model: kernelSessionId is the same numeric value exposed as scriptVersionId in the notebook session URL. kaggle kernels push returns that value as versionNumber, so kaggle kernels cancel <SESSION_ID> sends the identifier required by the cancellation endpoint. The SDK field names differ, but they do not represent different identifiers in this workflow, so I’m keeping the current documentation.

@sridipbasu

Copy link
Copy Markdown
Contributor

@ternaus
Thanks for the clarification! I think I understand the kernelSessionId / scriptVersionId part now, and I agree that those refer to the same identifier.

The part I'm still a little confused about is the versionNumber returned by kaggle kernels push. I went through the CLI flow again, and it looks like kernels push prints result.versionNumber, while kernels cancel passes the provided value directly as kernel_session_id.

I also noticed that the new docs describe <SESSION_ID> as the number printed after kernels push, but the example uses 341475263, whereas the existing push tests use values like 1 for versionNumber. So I'm not completely sure whether these are actually the same identifier in the real workflow.

@stevemessick Could you please help clarify this part? I might be missing something in the API/SDK mapping here, and I'd rather confirm it before pushing the review further.

If kernels push does indeed return the same scriptVersionId / kernelSessionId that kernels cancel expects, I'm happy to withdraw this concern. I just think it would be good to verify this once since the documentation depends on that relationship.

@stevemessick

Copy link
Copy Markdown
Contributor

/gcbrun

@stevemessick

Copy link
Copy Markdown
Contributor

kaggle k push returns the notebook version number, not the session ID. A session ID is like a *nix PID, and is not currently exposed outside the server. This function cannot be implemented yet.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add a CLI command to cancel an active kernel session

3 participants